import axios from 'axios';
const http = axios.create({
  baseURL: '/testApi/',
  transformRequest: [
    (data) => {
      return JSON.stringify(data);
    },
  ],
});

http.interceptors.request.use(
  async function (config) {
    return config;
  },
  function (error) {
    return Promise.reject(error);
  }
);

http.interceptors.response.use(
  function (response) {
    if (response.status === 200) {
      return response.data;
    } else {
      return response;
    }
  },
  function (error) {
    console.log(error);
  }
);

export default http;
